import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render,formattingMin, formattingDay, formatTimestamp } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '状态',
    align:"center",
    dataIndex: 'trash',
	customRender:({text})=>{
		if(text==false)return '可用'
		if(text==true)return '不可用'
	}
	
   },
   {
    title: '产品标题',
    align:"center",
    dataIndex: 'title'
   },
   {
    title: '售价',
    align:"center",
    dataIndex: 'perprice'
   },
   {
    title: '最小天数',
    align:"center",
    dataIndex: 'minday'
   },
   {
    title: '最大天数',
    align:"center",
    dataIndex: 'maxday'
   },
   {
    title: '保险公司价格',
    align:"center",
    dataIndex: 'thirdprice'
   },

   {
    title: '第三方保险代码',
    align:"center",
    dataIndex: 'thirdcode'
   },
   {
    title: '最大年龄',
    align:"center",
    dataIndex: 'maxage'
   },
   {
    title: '最小年龄',
    align:"center",
    dataIndex: 'minage'
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createtime',
	customRender:({text})=>{
		if(text.length<5){
			return ''
		}else{
			return formatTimestamp(text);
		}
	}
   },
   {
    title: '修改时间',
    align:"center",
    dataIndex: 'modifytime',
	customRender:({text})=>{
		if(text.length<5){
			return ''
		}
		return formatTimestamp(text);
	}
   },
   {
    title: '其他信息',
    align:"center",
    dataIndex: 'extinfor'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '状态',
    field: 'trash',
    component: 'JDictSelectTag',
    componentProps:{
		options:[
			{label:'可用',value:false},
			{label:'不可用',value:true}
		]
	}
  },
  {
    label: '产品标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入产品标题!'},
          ];
     },
  },
  {
    label: '保险公司价格',
    field: 'thirdprice',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入第三方价格!'},
          ];
     },
  },
  {
    label: '售价',
    field: 'perprice',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入人均单价!'},
          ];
     },
  },
  {
    label: '最小天数',
    field: 'minday',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入最小天数!'},
          ];
     },
  },
  {
    label: '最大天数',
    field: 'maxday',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入最大天数!'},
          ];
     },
  },

  {
    label: '第三方保险代码',
    field: 'thirdcode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入第三方保险代码!'},
          ];
     },
  },
  {
    label: '最大年龄',
    field: 'maxage',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入最大年龄!'},
          ];
     },
  },
  {
    label: '最小年龄',
    field: 'minage',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入最小年龄!'},
          ];
     },
  },
/*  {
    label: '创建时间',
    field: 'createtime',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入创建时间!'},
          ];
     },
  },
  {
    label: '修改时间',
    field: 'modifytime',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入修改时间!'},
          ];
     },
  }, */
  {
    label: '说明',
    field: 'msg',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



//子表列表数据
export const bsThirdinsurancelogColumns: BasicColumn[] = [
   {
    title: 'index01',
    align:"center",
    dataIndex: 'index01'
   },
   {
    title: '报名记录',
    align:"center",
    dataIndex: 'tourorderid'
   },
   {
    title: '状态..WaitPay，待付款；Sucess，付款成功；PayFail，付款失败；PayBack，退款',
    align:"center",
    dataIndex: 'stats'
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createtime'
   },
   {
    title: '提交数据',
    align:"center",
    dataIndex: 'detaildata'
   },
];
//子表表单数据
export const bsThirdinsurancelogFormSchema: FormSchema[] = [
  {
    label: 'index01',
    field: 'index01',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入index01!'},
          ];
     },
  },
  {
    label: '报名记录',
    field: 'tourorderid',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入报名记录!'},
          ];
     },
  },
  {
    label: '状态..WaitPay，待付款；Sucess，付款成功；PayFail，付款失败；PayBack，退款',
    field: 'stats',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入状态..WaitPay，待付款；Sucess，付款成功；PayFail，付款失败；PayBack，退款!'},
          ];
     },
  },
  {
    label: '创建时间',
    field: 'createtime',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入创建时间!'},
          ];
     },
  },
  {
    label: '提交数据',
    field: 'detaildata',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入提交数据!'},
          ];
     },
  },
];

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}